package com.taotao.springbootApi.mapper;

import com.taotao.springbootApi.entity.User;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from sys_user")
    List<User> getAll();

    @Select("select * from sys_user where id = #{id}")
    User getById(Integer id);

    @Select("select * from sys_user where username like concat('%',#{username},'%') limit #{pageNum},#{pageSize}")
    List<User> selectPage(Integer pageNum, Integer pageSize, String username);

    @Select("select count(*) from sys_user where username like concat('%',#{username},'%')")
    Integer selectTotal(String username);
    @Insert(" INSERT into sys_user(username,password,nickname,email,phone,address) "+
            "VALUES(#{username},#{password},#{nickname},#{email},#{phone},#{address})")
    void save(User user);

    @Delete("DELETE FROM sys_user WHERE id=#{id}")
    void delete(Integer id);

    @Update("update sys_user set username=#{username},password=#{password}," +
            "nickname=#{nickname},email=#{email},phone=#{phone},address=#{address} " +
            "where id = #{id}")
    void update(User user);
}
